package com.ruoyi.car.controller.carmanage;

import com.car.pojo.TbCarPreconfigured;
import com.car.vo.VoCarConfiged;
import com.ruoyi.car.service.carmanage.TbCarPreconfiguredService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆预配置的控制器
 * @Package:com.ruoyi.car.controller.carmanage
 * @Author:敬乾超 2020/6/26 20:25:32
 */
@Controller
@RequestMapping("/car/config")
public class TbCarPreconfiguredController extends BaseController {

    private String prefix = "carmanage/carconfig";

    @Autowired
    private TbCarPreconfiguredService tbCarPreconfiguredService;


    @GetMapping()
    @RequiresPermissions("car:config:view")
    public String carConfig(){
        return prefix + "/carConfigRecord";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo getCarPreconfigured(TbCarPreconfigured carPreconfigured){
        startPage();
        List<TbCarPreconfigured> carPreconfiguredList = tbCarPreconfiguredService.getCarPreconfigured(carPreconfigured);
        //logger.info("----------------------------请求了");
        return getDataTable(carPreconfiguredList);
    }

    /**
     * 查询配置名称下拉框
     * @param carPreconfigured
     * @return
     */
    @PostMapping("/listconfigName")
    @ResponseBody
    public List listconfigName(TbCarPreconfigured carPreconfigured){
        startPage();
        List<TbCarPreconfigured> carPreconfiguredList = tbCarPreconfiguredService.getCarPreconfigured(carPreconfigured);
        //logger.info("----------------------------请求了");
        return carPreconfiguredList;
    }






    /**
     * 通过Id查询详细参数
     * @param id
     * @return
     */
    @GetMapping("/getConfigById/{id}")
    @ResponseBody
    public TbCarPreconfigured getConfigById(@PathVariable("id") Long id){
        return tbCarPreconfiguredService.getConfigById(id);
    }

    @GetMapping("/getPartConfigById/{id}")
    @ResponseBody
    public VoCarConfiged getPartsConfigById(@PathVariable("id") Long id){
        logger.info("-------------"+id);
        return tbCarPreconfiguredService.getPartsConfigById(id);
    }

}
